home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / oobr / objc-brows.el < prev    next >
Encoding:
Text File  |  1995-05-05  |  4.2 KB  |  135 lines

  1. ;;!emacs
  2. ;;
  3. ;; FILE:         objc-brows.el
  4. ;; SUMMARY:      Objective-C source code browser.
  5. ;; USAGE:        GNU Emacs Lisp Library
  6. ;; KEYWORDS:     c, oop, tools
  7. ;;
  8. ;; AUTHOR:       Bob Weiner
  9. ;; ORG:          Motorola Inc.
  10. ;;
  11. ;; ORIG-DATE:    12-Dec-89
  12. ;; LAST-MOD:      5-May-95 at 14:11:18 by Bob Weiner
  13. ;;
  14. ;; Copyright (C) 1989-1995  Free Software Foundation, Inc.
  15. ;; See the file BR-COPY for license information.
  16. ;;
  17. ;; This file is part of the OO-Browser.
  18. ;;
  19. ;; DESCRIPTION:  
  20. ;;
  21. ;;    Use 'objc-browse' to invoke the Objective-C OO-Browser.  Prefix arg
  22. ;;    prompts for name of Environment file.
  23. ;;
  24. ;; DESCRIP-END.
  25.  
  26. (mapcar 'require '(br-start br br-objc-ft))
  27.  
  28. ;;; ************************************************************************
  29. ;;; Public functions
  30. ;;; ************************************************************************
  31.  
  32. ;; Cases
  33. ;; 
  34. ;; env-file = nil
  35. ;;   Use default environment, objc-env-file
  36. ;;   if objc not loaded, load it
  37. ;;   if objc-env-file != br-env-file
  38. ;;      switch to objc
  39. ;; 
  40. ;; env-file = t
  41. ;;   Prompt for env
  42. ;;   if env != objc
  43. ;;      load it
  44. ;;   else if env != br-env
  45. ;;      switch to env
  46. ;; 
  47. ;; env-file = filename
  48. ;;   if env != objc-env
  49. ;;      
  50. ;; 
  51. ;; objc-env-file = br-env-file
  52.  
  53. ;;;###autoload
  54. (defun objc-browse (&optional env-file no-ui)
  55.   "Invoke the Objective-C OO-Browser.
  56. This allows browsing through Objective-C library and system class
  57. hierarchies.  With an optional non-nil prefix argument ENV-FILE, prompt for
  58. Environment file to use.  Alternatively, a string value of ENV-FILE is used
  59. as the Environment file name.  See also the file \"br-help\"."
  60.   (interactive "P")
  61.   (let ((same-lang (equal br-lang-prefix objc-lang-prefix)))
  62.     (if same-lang
  63.     nil
  64.       (if br-lang-prefix
  65.       (br-env-copy nil)) ;; Save other language Environment in memory
  66.       (setq br-lang-prefix objc-lang-prefix
  67.         *br-save-wconfig* nil))
  68.     (let ((same-env (or (equal objc-env-file env-file)
  69.             (and (null env-file)
  70.                  (or objc-lib-search-dirs objc-sys-search-dirs)))))
  71.       (cond
  72.     ;; Continue browsing an Environment
  73.     ((and same-env same-lang))
  74.     ((and same-env (not same-lang))
  75.      (progn (objc-browse-setup) (br-env-copy t)))
  76.     ;;
  77.     ;; Create default Environment file specification if needed and none
  78.     ;; exists.
  79.     ;;
  80.     (t (or env-file (file-exists-p objc-env-file)
  81.            (br-env-create objc-env-file objc-lang-prefix))
  82.        (or env-file (setq env-file objc-env-file))
  83.        ;;
  84.        ;; Start browsing a new Environment.
  85.        ;;
  86.        (objc-browse-setup)
  87.        (setq *br-save-wconfig* nil
  88.          objc-env-file (br-env-init env-file same-lang nil)
  89.          objc-sys-search-dirs br-sys-search-dirs
  90.          objc-lib-search-dirs br-lib-search-dirs)))))
  91.   (br-init)
  92.   (or no-ui (br-browse)))
  93.  
  94. (defun objc-class-list-filter (class-list)
  95.   "Return CLASS-LIST sans any protocol or class category entries.
  96. Used when Environment classes are listed."
  97.   (delq nil (mapcar (function (lambda (class)
  98.                 (if (string-match "[\(\<]" class)
  99.                     nil
  100.                   class)))
  101.             class-list)))
  102.  
  103. (defun objc-mode-setup ()
  104.   "Load best available Objective-C major mode and set 'br-lang-mode' to the function that invokes it."
  105.   (fset 'br-lang-mode
  106.     (cond ((or (fboundp 'objc-mode) (featurep 'objc-mode)) 'objc-mode)
  107.           ((load "objc-mode" t 'nomessage) 'objc-mode)
  108.           ((featurep 'c-mode) 'c-mode)
  109.           ((load "cc-mode" 'missing-ok 'nomessage)
  110.            (if (fboundp 'objc-mode) 'objc-mode 'c-mode))
  111.           ((load "c-mode" nil 'nomessage)
  112.            (provide 'c-mode)))))
  113.  
  114. ;;; ************************************************************************
  115. ;;; Internal functions
  116. ;;; ************************************************************************
  117.  
  118. (defun objc-browse-setup ()
  119.   "Setup language-dependent functions for OO-Browser."
  120.   (br-setup-functions)
  121.   ;; Use this until an info function is implemented for the language.
  122.   (fmakunbound 'br-insert-class-info)
  123.   (fset 'br-store-class-info 'objc-store-class-info)
  124.   (objc-mode-setup)
  125.   (br-setup-constants)
  126.   ;; Setup to add default classes ([category] and [protocol]) to system class
  127.   ;; table after building it.  This must come after br-setup-constants call
  128.   ;; since it clears these hooks.
  129.   (if (fboundp 'add-hook)
  130.       (add-hook 'br-after-build-sys-hook 'objc-add-default-classes)
  131.     (setq br-after-build-sys-hook '(objc-add-default-classes))))
  132.  
  133.  
  134. (provide 'objc-brows)
  135.